import request from '@/config/axios'

// 派单系统 订单 VO
export interface OrderVO {
  id: number // 编号
  storeId: number // 门店编号
  orderType: number // 订单类型
  licensePlate: string // 车牌
  telephone: string // 联系电话
  vin: string // VIN
  remark: string // 备注
  status: number // 开启状态
  sort: number // 排序
  carType: string // 车型
  customerName: string // 客户名称
  customerAddrress: string // 客户地址信息
  orderPrice: number // 订单价格
  dispatchPrice: number // 派单状态
  auditStatus: number // 审核状态
  checkStatus: number // 对账状态
  payStatus: number // 付款状态
}

// 派单系统 订单 API
export const OrderApi = {
  // 查询派单系统 订单分页
  getOrderPage: async (params: any) => {
    return await request.get({url: `/dispatch/order/page`, params})
  },

  //订单跟踪
  getOrderTailPage: async (params: any) => {
    return await request.get({url: `/dispatch/order/pageTail`, params})
  },

  //历史价格
  selectHistoryPriceRecord: async (productId: any) => {
    return await request.get({url: `/dispatch/order/selectHistoryPriceRecord?productId=`+productId})
  },

  // 查询派单系统 订单详情
  getOrder: async (id: number) => {
    return await request.get({url: `/dispatch/order/get?id=` + id})
  },

  // 新增派单系统 订单
  createOrder: async (data: OrderVO) => {
    return await request.post({url: `/dispatch/order/create`, data})
  },
  //创建付款单
  createPaymentOrder: async (data: OrderVO) => {
    return await request.post({url: `/dispatch/order/createPaymentOrder`, data})
  },

  batchCreatePaymentOrder: async (data: OrderVO) => {
    return await request.post({url: `/dispatch/order/batchCreatePaymentOrder`, data})
  },



  // 修改派单系统 订单
  updateOrder: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/update`, data})
  },

  dealPicAuditDate: async (data) => {
    return await request.put({url: `/dispatch/order/dealPicAuditDate`, data})
  },


  //取消派单
  cancelDispatch: async (id: number) => {
    return await request.put({url: `/dispatch/order/cancelDispatch/`+id})
  },


  /**
   * 派单
   * @param data
   */
  handleDispatch: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/handleDispatch`, data})
  },
  /**
   * 上传图片
   * @param data
   */
  handlePic: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/handlePic`, data})
  },
  /**
   * 修改订单价格
   * @param orderPriceData
   */
  updateOrderPrice: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/updateOrderPrice`, data})
  },
  /**
   * 修改派单价格
   * @param dispatchPriceData
   */
  updateDispatchPrice: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/updateDispatchPrice`, data})
  },

  /**
   * 审核状态
   * @param data
   */
  handleAuditStatus: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/handleAuditStatus`, data})
  },

  /**
   * 对账状态
   * @param data
   */
  handleCheckStatus: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/handleCheckStatus`, data})
  },

  /**
   * 付款状态
   * @param data
   */
  handlePayStatus: async (data: OrderVO) => {
    return await request.put({url: `/dispatch/order/handlePayStatus`, data})
  },

  // 删除派单系统 订单
  deleteOrder: async (id: number) => {
    return await request.delete({url: `/dispatch/order/delete?id=` + id})
  },

  // 导出派单系统 订单 Excel
  exportOrder: async (params) => {
    return await request.download({url: `/dispatch/order/export-excel`, params})
  }

}
